'use strict';
module.exports = {
	/**
	 * 特别重要！！！
	 * 特别重要！！！
	 * 特别重要！！！
	 * 这个页面是广告系统第三方监测链接的数据接收函数，切勿删除！
	 */
	main: async (event) => {
		const db = uniCloud.database();
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, _ } = util;
		let { uid, pt, ad_id, idfa, imei, mac, ip, ua, timestamp, aid, cid, callback, tfid, invite_code } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		var time = new Date().getTime()
		if (callback) {
			let addchudian = await db.collection('jl_chudian').add({
				pt: "kuaishou", //平台
				tfid: tfid || 0,
				invite_code: invite_code || 0,
				uid: uid,
				idfa: idfa, //iOS设备ID
				imei: imei, //安卓设备ID
				mac: mac,
				ad_id: aid,
				cid: cid,
				ip: ip,
				ua: ua,
				timestamp: timestamp,
				callback: callback,
				time: time,
				time_str: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd hh:mm:ss")
			})
		}

		res.context = originalParam.context

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
